﻿Module mHits

    Public Sub DrawHitIndicators(ByRef lstHits As List(Of Player.HitIndicator), ByVal x As Integer, ByVal y As Integer)

        If lstHits.Count = 0 Then Exit Sub

        Dim strText As String
        Dim startnumidx As Integer
        Dim i As Integer, c As Integer, tx As Integer
        Dim hit As Player.HitIndicator

        For id As Integer = 0 To lstHits.Count - 1

            If id >= lstHits.Count Then Exit For

            hit = lstHits(id)

            strText = hit.val.ToString
            If Left(strText, 1) <> "-" And hit.val <> 0 Then strText = "+" & strText

            If hit.val < 0 And hit.val > -100 Then
                startnumidx = 1791
            ElseIf hit.val < -99 And hit.val > -500 Then
                startnumidx = 1831
            ElseIf hit.val < -499 Then
                startnumidx = 1751
            ElseIf hit.val > 0 Then
                startnumidx = 1811
            ElseIf hit.val = 0 Then
                'miss
                startnumidx = 1851
            End If

            For i = 1 To strText.Length

                If IsNumeric(Mid(strText, i, 1)) Then
                    c = Mid(strText, i, 1)
                ElseIf Mid(strText, i, 1) = "-" Then
                    c = 10
                ElseIf Mid(strText, i, 1) = "+" Then
                    c = 11
                End If

                If Not Libs.GameInter.Image(startnumidx + c).HasImage Then
                    Dim break As Integer
                    break = 0
                End If
                Libs.GameInter.Image(startnumidx + c).Draw(x + hit.xoff + tx, y + hit.yoff, 0.21)
                tx += Libs.GameInter.Image(startnumidx + c).Header.Width + 2

            Next

            If DateTime.Now.Ticks >= hit.movtick Then

                hit.movtick += 600000
                hit.xoff += 1
                hit.yoff -= 3

                If hit.xoff = 16 Then
                    lstHits.RemoveAt(id)
                Else
                    lstHits(id) = hit
                End If

            End If

            tx = 0

        Next

    End Sub

    Public Sub AddHitIndicator(ByRef lstHits As List(Of Player.HitIndicator), ByVal hpdif As Integer)

        Dim tmp As Player.HitIndicator

        tmp.movtick = DateTime.Now.Ticks + 600000
        tmp.val = hpdif

        lstHits.Add(tmp)

    End Sub

End Module
